package com.example.concurrent.ExecutorService;

import java.util.concurrent.*;

/**
 * Created by Administrator on 2017/2/10 0010.
 */
public class submitRunnableDemo {

    public static void main(String[] args) {


        ExecutorService executorService = Executors.newSingleThreadExecutor();

        try {
            Future future = executorService.submit(new Runnable() {
                public void run() {
                    System.out.println("Asynchronous task");
                }
            });
            future.get();
            //returns null if the task has finished correctly.
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        executorService.shutdown();


    }
}
